package cn.monkey.family.rbac.dsl;

import lombok.Getter;

public interface RequestPredicate<T> {

    @Getter
    enum MatchResult {
        NO_MATCH(0);
        private final int value;

        MatchResult(int value) {
            this.value = value;
        }
    }

    int test(T t);

    default RequestPredicate<T> and(RequestPredicate<T> other) {
        return t -> this.test(t) & other.test(t);
    }

    default RequestPredicate<T> or(RequestPredicate<T> other) {
        return t -> this.test(t) | other.test(t);
    }
}
